<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    text: String,
    showClose: Boolean,
    border: Boolean,
    isActive: Boolean,
  },
  emits: {
    "close-click": () => true,
  },
  setup(props, ctx) {
    const closeClick = () => {
      ctx.emit("close-click");
    };

    return { closeClick };
  },
});
</script>

<template>
  <view
    class="tag-item"
    :style="{
      borderColor: isActive && border ? '#ff7900' : '',
      backgroundColor: isActive ? 'rgba(255, 121, 0, 0.08)' : '',
    }"
  >
    <view class="tag-item-text" :style="{ color: isActive ? '#ff7900' : '' }">
      {{ text }}
    </view>
    <image
      class="tag-item-close"
      v-if="showClose"
      :src="
        isActive
          ? '/package/my/static/guider-tag-close2.png'
          : '/package/my/static/guider-tag-close.png'
      "
      @click.stop="closeClick"
    />
  </view>
</template>

<style lang="scss">
.tag-item {
  display: flex;
  align-items: center;
  height: 56rpx;
  padding: 0 18rpx;
  border-radius: 10rpx;
  border: 2rpx solid #f5f5f5;
  background-color: #f5f5f5;

  .tag-item-text {
    font-size: 24rpx;
    color: #333333;
    line-height: 34rpx;
  }

  .tag-item-close {
    width: 24rpx;
    height: 24rpx;
    margin-left: 10rpx;
  }
}
</style>